import uicls
import uiconst
import uthread
import blue

class DividerCore(uicls.Container):
    __guid__ = 'uicls.DividerCore'

    def _Initialize(self, *args, **kw):
        uicls.Container._Initialize(self, *args, **kw)
        self._dragging = False
        self._initCursor = None
        self.state = uiconst.UI_NORMAL



    def _OnMouseDown(self, *args):
        self.OnChangeStart_(self)
        self._dragging = True
        self._initCursor = (uicore.uilib.x, uicore.uilib.y)
        uthread.new(self.BeginChange)



    def BeginChange(self, *args):
        while self._dragging:
            diffx = (uicore.uilib.x - self._initCursor[0])
            diffy = (uicore.uilib.y - self._initCursor[1])
            self.OnChange_(self, diffx, diffy)
            blue.pyos.synchro.Sleep(1)




    def _OnMouseUp(self, *args):
        self._dragging = False
        self.OnChanged_(self)



    def OnChangeStart_(self, *args):
        return 



    def OnChange_(self, *args, **kw):
        return 



    def OnChanged_(self, *args):
        return 




